/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.models.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "tblTopic", catalog = "cungonbaiDB", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TblTopic.findAll", query = "SELECT t FROM TblTopic t"),
    @NamedQuery(name = "TblTopic.findByTopicId", query = "SELECT t FROM TblTopic t WHERE t.topicId = :topicId"),
    @NamedQuery(name = "TblTopic.findByCreateDate", query = "SELECT t FROM TblTopic t WHERE t.createDate = :createDate"),
    @NamedQuery(name = "TblTopic.findByTopicLevel", query = "SELECT t FROM TblTopic t WHERE t.topicLevel = :topicLevel"),
    @NamedQuery(name = "TblTopic.findByUploadDate", query = "SELECT t FROM TblTopic t WHERE t.uploadDate = :uploadDate")})
public class TblTopic implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "topicId", nullable = false)
    private Integer topicId;
    @Column(name = "createDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createDate;
    @Column(name = "topicLevel")
    private Integer topicLevel;
    @Column(name = "uploadDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date uploadDate;
    @ManyToMany(mappedBy = "tblTopicList")
    private List<TblQuestion> tblQuestionList;
    @JoinColumn(name = "subjectId", referencedColumnName = "subjectId")
    @ManyToOne
    private TblSubject subjectId;
    @OneToMany(mappedBy = "topicId")
    private List<TblRoom> tblRoomList;

    public TblTopic() {
    }

    public TblTopic(Integer topicId) {
        this.topicId = topicId;
    }

    public Integer getTopicId() {
        return topicId;
    }

    public void setTopicId(Integer topicId) {
        this.topicId = topicId;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Integer getTopicLevel() {
        return topicLevel;
    }

    public void setTopicLevel(Integer topicLevel) {
        this.topicLevel = topicLevel;
    }

    public Date getUploadDate() {
        return uploadDate;
    }

    public void setUploadDate(Date uploadDate) {
        this.uploadDate = uploadDate;
    }

    @XmlTransient
    public List<TblQuestion> getTblQuestionList() {
        return tblQuestionList;
    }

    public void setTblQuestionList(List<TblQuestion> tblQuestionList) {
        this.tblQuestionList = tblQuestionList;
    }

    public TblSubject getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(TblSubject subjectId) {
        this.subjectId = subjectId;
    }

    @XmlTransient
    public List<TblRoom> getTblRoomList() {
        return tblRoomList;
    }

    public void setTblRoomList(List<TblRoom> tblRoomList) {
        this.tblRoomList = tblRoomList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (topicId != null ? topicId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblTopic)) {
            return false;
        }
        TblTopic other = (TblTopic) object;
        if ((this.topicId == null && other.topicId != null) || (this.topicId != null && !this.topicId.equals(other.topicId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.models.entities.TblTopic[ topicId=" + topicId + " ]";
    }
    
}
